import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import java.awt.FlowLayout;
import javax.swing.JLabel;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ButtonGroup;
import javax.swing.JTextField;
import javax.swing.JRadioButton;
import javax.swing.JComboBox;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JRadioButtonMenuItem;

/**
 * 
 * @author Taylor Holden
 *
 * WindowBuilderPro generated code. Player configuration UI.
 */


public class PlayerConfiguration extends JFrame {

	private JPanel contentPane;
	private JTextField textField;
	private JTextField textField_1;
	private JTextField textField_2;
	private JTextField textField_3;
	private JTextField textField_4;
	private boolean hasFinished;
	private JRadioButton rdbtnNewRadioButton;
	private JRadioButton rdbtnNewRadioButton_1;
	private JRadioButton rdbtnNewRadioButton_2;
	private JComboBox comboBox;
	private JComboBox comboBox_1;
	private ButtonGroup professionGroup;

	/**
	 * Create the frame.
	 */
	public PlayerConfiguration() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		hasFinished = false;
		setBounds(100, 100, 800, 600);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JLabel lblNewLabel = new JLabel("Player Name:");
		lblNewLabel.setFont(new Font("Tahoma", Font.PLAIN, 14));
		lblNewLabel.setBounds(29, 29, 86, 17);
		contentPane.add(lblNewLabel);
		
		textField = new JTextField();
		textField.setBounds(125, 29, 170, 20);
		contentPane.add(textField);
		textField.setColumns(30);
		
		rdbtnNewRadioButton = new JRadioButton("Banker");
		rdbtnNewRadioButton.setSelected(true);
		rdbtnNewRadioButton.setBounds(29, 186, 109, 23);
		contentPane.add(rdbtnNewRadioButton);
		
		rdbtnNewRadioButton_1 = new JRadioButton("Carpenter");
		rdbtnNewRadioButton_1.setBounds(169, 186, 109, 23);
		contentPane.add(rdbtnNewRadioButton_1);
		
		rdbtnNewRadioButton_2 = new JRadioButton("Farmer");
		rdbtnNewRadioButton_2.setBounds(322, 186, 109, 23);
		contentPane.add(rdbtnNewRadioButton_2);
		
		professionGroup = new ButtonGroup();
		professionGroup.add(rdbtnNewRadioButton);
		professionGroup.add(rdbtnNewRadioButton_1);
		professionGroup.add(rdbtnNewRadioButton_2);
		
		JLabel lblChooseAProfession = new JLabel("Choose a Profession:");
		lblChooseAProfession.setFont(new Font("Tahoma", Font.PLAIN, 14));
		lblChooseAProfession.setBounds(29, 118, 155, 25);
		contentPane.add(lblChooseAProfession);
		
		comboBox = new JComboBox();
		comboBox.setModel(new DefaultComboBoxModel(new String[] {"Stopped", "Leisurely", "Steady", "Grueling"}));
		comboBox.setFont(new Font("Tahoma", Font.PLAIN, 12));
		comboBox.setBounds(629, 28, 109, 20);
		contentPane.add(comboBox);
		
		JLabel lblNewLabel_1 = new JLabel("Initial Pace:");
		lblNewLabel_1.setFont(new Font("Tahoma", Font.PLAIN, 14));
		lblNewLabel_1.setBounds(551, 30, 68, 14);
		contentPane.add(lblNewLabel_1);
		
		JLabel lblInitialRations = new JLabel("Initial Rations:");
		lblInitialRations.setFont(new Font("Tahoma", Font.PLAIN, 14));
		lblInitialRations.setBounds(533, 122, 86, 17);
		contentPane.add(lblInitialRations);
		
		comboBox_1 = new JComboBox();
		comboBox_1.setFont(new Font("Tahoma", Font.PLAIN, 12));
		comboBox_1.setModel(new DefaultComboBoxModel(new String[] {"None", "Bare-Bones", "Meager", "Normal", "Well-Fed"}));
		comboBox_1.setBounds(629, 121, 109, 20);
		contentPane.add(comboBox_1);
		
		JLabel lblPartyMemebers = new JLabel("Party Memebers:");
		lblPartyMemebers.setFont(new Font("Tahoma", Font.PLAIN, 14));
		lblPartyMemebers.setBounds(10, 381, 130, 20);
		contentPane.add(lblPartyMemebers);
		
		JLabel lblPartyMember = new JLabel("Party Member 1:");
		lblPartyMember.setFont(new Font("Tahoma", Font.PLAIN, 12));
		lblPartyMember.setBounds(10, 424, 97, 14);
		contentPane.add(lblPartyMember);
		
		JLabel lblPartyMember_1 = new JLabel("Party Member 2:");
		lblPartyMember_1.setFont(new Font("Tahoma", Font.PLAIN, 12));
		lblPartyMember_1.setBounds(10, 449, 97, 14);
		contentPane.add(lblPartyMember_1);
		
		JLabel lblPartyMember_2 = new JLabel("Party Member 3:");
		lblPartyMember_2.setFont(new Font("Tahoma", Font.PLAIN, 12));
		lblPartyMember_2.setBounds(10, 474, 97, 14);
		contentPane.add(lblPartyMember_2);
		
		JLabel lblPartyMember_3 = new JLabel("Party Member 4:");
		lblPartyMember_3.setFont(new Font("Tahoma", Font.PLAIN, 12));
		lblPartyMember_3.setBounds(10, 499, 97, 17);
		contentPane.add(lblPartyMember_3);
		
		textField_1 = new JTextField();
		textField_1.setColumns(30);
		textField_1.setBounds(125, 422, 170, 20);
		contentPane.add(textField_1);
		
		textField_2 = new JTextField();
		textField_2.setColumns(30);
		textField_2.setBounds(125, 447, 170, 20);
		contentPane.add(textField_2);
		
		textField_3 = new JTextField();
		textField_3.setColumns(30);
		textField_3.setBounds(125, 472, 170, 20);
		contentPane.add(textField_3);
		
		textField_4 = new JTextField();
		textField_4.setColumns(30);
		textField_4.setBounds(125, 498, 170, 20);
		contentPane.add(textField_4);
		
		JButton btnStartGame = new JButton("Start Game");
		btnStartGame.setBounds(612, 497, 126, 23);
		contentPane.add(btnStartGame);
		btnStartGame.addActionListener(new StartButtonListener());
	}
	
	public String[] getNames()
	{
		String[] names = new String[5];
		
		names[0] = textField.getText();
		names[1] = textField_1.getText();
		names[2] = textField_2.getText();
		names[3] = textField_3.getText();
		names[4] = textField_4.getText();
		
		return names;
	}
	
	public Profession getProfession()
	{
		if(rdbtnNewRadioButton.isSelected())
			return new Banker();
		else if(rdbtnNewRadioButton_1.isSelected())
			return new Carpenter();
		else
			return new Farmer();
	}
	
	public int getPace()
	{
		return comboBox.getSelectedIndex();
	}
	
	public int getRations()
	{
		return comboBox_1.getSelectedIndex();
	}
	
	public boolean hasFinished()
	{
		return hasFinished;
	}
	
	class StartButtonListener implements ActionListener
	{
		@Override
		public void actionPerformed(ActionEvent e) 
		{
			if(!(textField.getText().equals("") || textField_1.getText().equals("") || textField_2.getText().equals("") || textField_3.getText().equals("") || textField_4.getText().equals("") || (!rdbtnNewRadioButton.isSelected() && !rdbtnNewRadioButton_1.isSelected() && !rdbtnNewRadioButton_2.isSelected()) ))
				hasFinished = true;
			else
				System.out.println("Not done, sir.");
		}
	}
}
